package part1.api.collection.collectiontest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class IteratorDemo {

    public static void main(String[] args) {
        Collection<Point> c = new ArrayList();
        c.add(new Point(1,2));
        c.add(new Point(3,4));
        c.add(new Point(5,6));
        c.add(new Point(1,2));
        Point z = new Point(1,2);
        Iterator<Point> it = c.iterator();
        while (it.hasNext()){
            Point p = it.next();
            System.out.println(p);
            if (z.equals(p)){
                it.remove();
            }
        }
        System.out.println(c);
        System.out.println("---");
        for (Point p : c){
            System.out.println(p);
        }
    }
}
